package Operation;

import book.BookList;

import java.util.Scanner;

public class FindOperation  implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("查找书籍");
        System.out.println("请输入要查找的书籍名字:");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int n = bookList.getBooknum();
        boolean found = true;
        for (int i = 0; i < n; i++) {
            if (name.equals(bookList.getBooks()[i].getName())) {
                System.out.println("找到了你要的书！");
                System.out.println(bookList.getBooks()[i]);
                found = false;
            }
        }
        if(found){
            System.out.println("对不起，你没有这本书！");
        }
    }
}

